

#ifndef NODEDIVIDE_H
#define	NODEDIVIDE_H

#include <QtGui>
#include "Node.h"

class NodeDivide : public Node {

    Q_OBJECT

public:
    NodeDivide()
    : Node(QString("divide"), 2, QString("/")) {
        // add the layout
        QVBoxLayout* layout = new QVBoxLayout(this);
        //        layout->setAlignment(Qt::AlignHCenter);
        layout->setSpacing(1);
        layout->setContentsMargins(1, 1, 1, 1);

        // add the divide line
        QFrame * line = new QFrame();
        line->setObjectName(QString::fromUtf8("line"));
        line->setFrameShape(QFrame::HLine);
        line->setLineWidth(2);
        line->setFrameShadow(QFrame::Plain);
        layout->addWidget(line);
    }

    QString toCasString() const {
        Q_ASSERT_X(getLeftChild() != 0, "Node::toCasString",
                "Could not find left hand child node.");
        Q_ASSERT_X(getRightChild() != 0, "Node::toCasString",
                "Could not find right hand child node.");
        Q_ASSERT_X(numChildren() == 2, "Node::toCasString",
                "Expected two children.");
        QString str;
        str.append("(");
        if (getLeftChild()->getNodeType() == "empty") str.append("1");
        else str.append(getLeftChild()->toCasString());
        str.append(getNodeValue());
        if (getRightChild()->getNodeType() == "empty") str.append("1");
        else str.append(getRightChild()->toCasString());
        str.append(")");
        return str;
    }
};



#endif	/* NODEDIVIDE_H */

